public class GenericsTest {
    // 未使用泛型
    public static void test01(Object o){
        //此时会产生类型转换异常ClassCastException
       Person person = (Person) o;
        System.out.println(person.getAge());
        System.out.println(person.getName());
    }

    public static void main(String[] args) {
        Person person = new Person("张三", 18);
        Dog dog = new Dog("旺财", 2);
        test01(dog);

    }
    static class Person{
        private String name;
        private int age;

        public Person(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }
    static class Dog{
        private String name;
        private int age;

        public Dog(String name, int age) {
            this.name = name;
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }
    }
}
